import 'package:built_collection/built_collection.dart';
import 'package:equatable/equatable.dart';
import 'package:learning_content_admin_pannel.core/core/domain/entities/learning_content/ui_locale.dart';

sealed class CollectionListItem {
  String get id;

  BuiltMap<UILocale, String> get titles;

  CollectionListItem copyWith({
    String Function()? id,
    BuiltMap<UILocale, String> Function()? titles,
  });
}

class Collection extends Equatable implements CollectionListItem {
  const Collection({
    required this.id,
    required this.titles,
    required this.lexicalItemIds,
  });

  @override
  final String id;

  @override
  final BuiltMap<UILocale, String> titles;

  final BuiltSet<String> lexicalItemIds;

  @override
  List<Object?> get props {
    return [
      id,
      titles,
      lexicalItemIds,
    ];
  }

  @override
  Collection copyWith({
    String Function()? id,
    BuiltMap<UILocale, String> Function()? titles,
    BuiltSet<String> Function()? lexicalItemIds,
  }) {
    return Collection(
      id: id == null ? this.id : id(),
      titles: titles == null ? this.titles : titles(),
      lexicalItemIds:
          lexicalItemIds == null ? this.lexicalItemIds : lexicalItemIds(),
    );
  }
}

class CollectionFolder extends Equatable implements CollectionListItem {
  const CollectionFolder({
    required this.id,
    required this.titles,
    required this.collections,
  });

  @override
  final String id;

  @override
  final BuiltMap<UILocale, String> titles;

  final BuiltList<Collection> collections;

  @override
  List<Object?> get props {
    return [
      id,
      titles,
      collections,
    ];
  }

  @override
  CollectionFolder copyWith({
    String Function()? id,
    BuiltMap<UILocale, String> Function()? titles,
    BuiltList<Collection> Function()? collections,
  }) {
    return CollectionFolder(
      id: id == null ? this.id : id(),
      titles: titles == null ? this.titles : titles(),
      collections: collections == null ? this.collections : collections(),
    );
  }
}
